from zhipuai import ZhipuAI
client = ZhipuAI(api_key="270ea062fd48e631d31ac79585c87d7f.2f6XYjYw9N0oSSJB") # 填写您自己的APIKey
def check_keyword_in_string(input_string):
  response = client.chat.completions.create(
    model="glm-4-9b:883342770::ltosovmf",  # 填写需要调用的模型编码
    messages=[
        {"role": "system", "content": "你是CNE的关键字核查人员  我给你一段字符串  根据关键词  数据给NCC   如果包含 数据给NCC  请输出 YES 如果不包含就输出 NO"},
        {"role": "user", "content": "weaver.interfaces.schedule.ScheduleManage.jobToBeExecuted() - Schedule 监听类 "},
        {"role": "assistant", "content": "NO"},
        {"role": "user", "content": "chatResourceview.html?resourcetype=0resourceid=890957isFormMsg=1 "},
        {"role": "assistant", "content": "NO"},
        {"role": "user", "content": "actiondbid  ) VALUES (  向NCC推送出差申请单数据"},
        {"role": "assistant", "content": "NO"},
        {"role": "user", "content": "cc.util.SyncUtil.callApi() - 发送数据给NCC：token: "},
        {"role": "assistant", "content": "YES"},
        {"role": "user", "content": input_string}
    ],
  )
  return  response.choices[0].message.content




def print_file_line_by_line(file_path):
    """
    从指定文件中逐行读取并打印内容。

    :param file_path: 文件的路径
    """
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            for line in file:
                #print(line.strip())  # 使用 strip() 去除每行末尾的换行符
                str1 = check_keyword_in_string(line.strip()) 
                print(line.strip())
                print(str1)

    except FileNotFoundError:
        print(f"错误：文件 '{file_path}' 未找到。")
    except Exception as e:
        print(f"发生错误：{str(e)}")


def main():
        #result = check_keyword_in_string('ssssssssss')
        #print(f"结果: {result}")
        print_file_line_by_line('nccdata21')  

if __name__ == "__main__":
    main()




